package com.lap.auth.domain.shared.errors;

import com.lap.framework.dto.result.ErrorCode;
import lombok.Getter;

/**
 * 异常码规范
 *
 * <ol>
 *   <li>内部错误码(internalCode)提供是上报错误使用，命名规范[系统]-[模块]-[异常级别]-[编号]
 *   <li>建议编码从 005开始，预留模块错误
 *   <li>国际化键规范:
 *       <ul>
 *         <li>功能块错误:功能块.error
 *         <li>功能块通用:功能块.xxx.error
 *         <li>功能错误: 功能块.功能名称.error.具体(字段)
 *       </ul>
 * </ol>
 *
 * @author Shuisheng Lao(劳水生)
 * @version 0.0.1
 */
@Getter
public enum UserError implements ErrorCode {

  // 用户模块
  USER_NOT_FOUND("AUTH-USER-P2-005", "user.notfound.error"),
  USER_EXISTS("AUTH-USER-P2-006", "user.create.error.username_exists"),
  USER_STATUS_FAIL("AUTH-USER-P2-007", "user.change.error.status_not_change"),
  USER_CHANGE_NOT_ALLOW("AUTH-USER-P2-008", "user.change.error.not_allow"),
  USER_ROLE_NOT_MATCH("AUTH-USER-P2-009", "user.assign.error.not_match"),

  // 角色模块
  ROLE_NOT_FOUND("AUTH-ROLE-P2-005", "role.notfound.error"),
  ROLE_EXISTS("AUTH-ROLE-P2-006", "role.create.error.code_exists"),

  // 菜单模块
  MENU_NOT_FOUND("AUTH-MENU-P2-005", "menu.notfound.error"),
  MENU_NOT_CONTAINER("AUTH-MENU-P2-006", "menu.create.error.not_container"),
  MENU_CONTAINER("AUTH-MENU-P2-007", "menu.update.error.container"),
  MENU_HAS_CHILD("AUTH-MENU-P2-008", "menu.delete.error.has_child"),

  // 部门模块
  DEPT_NOT_FOUND("AUTH-DEPT-P2-005", "dept.notfound.error"),
  DEPT_HAS_CHILD("AUTH-DEPT-P2-006", "dept.delete.error.has_child"),

  // 项目模块
  PROJECT_NOT_FOUND("AUTH-PROJECT-P2-005", "project.notfound.error"),
  PROJECT_EXISTS("AUTH-PROJECT-P2-006", "project.create.error.code_exists"),

  // 区域模块
  REGION_NOT_FOUND("AUTH-REGION-P2-005", "region.notfound.error"),
  REGION_EXISTS("AUTH-REGION-P2-006", "region.create.error.code_exists"),
  REGION_HAS_CHILD("AUTH-REGION-P2-007", "region.delete.error.has_child"),

  // 模板模块
  MSG_TEMPLATE_NOT_FOUND("AUTH-MT-P2-005", "msgTemplate.notfound.error"),
  MSG_TEMPLATE_EXISTS("AUTH-MT-P2-006", "msgTemplate.create.error.code_exists"),

  // 字典类型模块
  DICT_TYPE_NOTFOUND("AUTH-DICT_TYPE-P2-005", "dictType.notfound.error"),
  DICT_TYPE_EXISTS("AUTH-DICT_TYPE-P2-005", "dictType.create.error.code_exists"),

  // 登录模块
  LOGIN_FAIL("AUTH-LOGIN-P2-001", "login.error"),

  // 无权限,
  NO_AUTH("AUTH-AUTH-P2-001", "auth.error"),
  ;

  private final String internalCode;
  private final String messageKey;

  UserError(String internalCode, String messageKey) {
    this.internalCode = internalCode;
    this.messageKey = messageKey;
  }
}
